package com.easybuy.entity;
/**
 * EasybuyProduct 实体类
 * 对应数据库表 easybuy.easybuy_product
 */
public class EasybuyProduct {
    // 主键
    private Integer id;

    // 名称
    private String name;

    // 描述
    private String description;

    // 价格
    private Float price;

    // 库存
    private Integer stock;

    // 分类1
    private Integer categoryLevel1Id;

    // 分类2
    private Integer categoryLevel2Id;

    // 分类3
    private Integer categoryLevel3Id;

    // 文件名称
    private String fileName;

    // 是否删除(1：删除 0：未删除)
    private Integer isDelete;

    // 无参构造函数
    public EasybuyProduct() {
    }

    // 带参构造函数
    public EasybuyProduct(Integer id, String name, String description, Float price,
                         Integer stock, Integer categoryLevel1Id, Integer categoryLevel2Id,
                         Integer categoryLevel3Id, String fileName, Integer isDelete) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.price = price;
        this.stock = stock;
        this.categoryLevel1Id = categoryLevel1Id;
        this.categoryLevel2Id = categoryLevel2Id;
        this.categoryLevel3Id = categoryLevel3Id;
        this.fileName = fileName;
        this.isDelete = isDelete;
    }

    // Getter 和 Setter 方法
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public Integer getCategoryLevel1Id() {
        return categoryLevel1Id;
    }

    public void setCategoryLevel1Id(Integer categoryLevel1Id) {
        this.categoryLevel1Id = categoryLevel1Id;
    }

    public Integer getCategoryLevel2Id() {
        return categoryLevel2Id;
    }

    public void setCategoryLevel2Id(Integer categoryLevel2Id) {
        this.categoryLevel2Id = categoryLevel2Id;
    }

    public Integer getCategoryLevel3Id() {
        return categoryLevel3Id;
    }

    public void setCategoryLevel3Id(Integer categoryLevel3Id) {
        this.categoryLevel3Id = categoryLevel3Id;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    // 便捷方法：判断商品是否已删除
    public boolean isDeleted() {
        return isDelete != null && isDelete == 1;
    }

    // 便捷方法：设置商品删除状态
    public void setDeleted(boolean deleted) {
        this.isDelete = deleted ? 1 : 0;
    }

    // 便捷方法：检查库存是否充足
    public boolean isStockSufficient(int requiredQuantity) {
        return stock != null && stock >= requiredQuantity;
    }

    // 便捷方法：获取商品图片URL（假设图片存储在指定目录）
    public String getImageUrl() {
        if (fileName != null && !fileName.trim().isEmpty()) {
            return "/uploads/products/" + fileName;
        }
        return "/images/default-product.png";
    }

    @Override
    public String toString() {
        return "EasybuyProduct{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", price=" + price +
                ", stock=" + stock +
                ", categoryLevel1Id=" + categoryLevel1Id +
                ", categoryLevel2Id=" + categoryLevel2Id +
                ", categoryLevel3Id=" + categoryLevel3Id +
                ", fileName='" + fileName + '\'' +
                ", isDelete=" + isDelete +
                '}';
    }
}